package com.eh.test;

import com.eh.http.HttpUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.concurrent.Executors;

/**
 * Created by David Li on 2016/5/18.
 */
@WebServlet(urlPatterns = "/api/hello.do", loadOnStartup = 0)
public class HelloServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        resp.sendRedirect("http://act.vip.com/27117.html?bid=833507");
        String str = HttpUtil.sendGet("http://act.vip.com/27117.html?bid=833507", "");
        resp.setContentType("text/html;charset=UTF-8");
        PrintWriter out = resp.getWriter();
        out.println(str);
        out.close();
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        //        String name = new String(req.getParameter("name").getBytes("ISO-8859-1"), "utf-8");
        String name = req.getParameter("name");
    }

    @Override
    public void init() throws ServletException {
        System.out.println("hello, test");
    }
}
